package com.mimiwang.school.controller;

import com.mimiwang.common.utils.ResponseUtil;
import com.mimiwang.school.service.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @AUTHOR:游李滨
 * @DATE:2023/5/1 15:57
 */

@RestController
@RequestMapping("/address")
public class AddressController {


    @Autowired
    IAddressService addressService;

    @GetMapping("/province")
    String getAllProvince(){

       return  ResponseUtil.successJSONData(addressService.selectAllProvince());
    }


    @GetMapping("/city")
    String getCityListByPId(long pId){
        if( pId <= 0 ){
           return ResponseUtil.successJSONData();
        }
        return ResponseUtil.successJSONData(addressService.selectCityListByProvinceId(pId));
    }
}
